package com.ruicar.afs.cloud.contract.gateway.processor.value;

import cn.hutool.core.util.ObjectUtil;
import com.ruicar.afs.cloud.contract.gateway.enums.ProcessorName;
import org.springframework.stereotype.Component;

/**
 * The type DefaultProcessor
 * <p>Description: </p>
 *
 * @author Fzero
 * @version 1.0
 * @date Created on 2020.07.19 14:24:16
 * @since 1.0
 */
@Component
public class DefaultValueProcessor implements ValueProcessor<Object,Object>{
    /**
     * Process object
     *
     * @param sourceValue  source value
     * @param defaultValue default value
     * @return the object
     */
    @Override
    public Object process(Object sourceValue, Object defaultValue) {
        return ObjectUtil.isNull(sourceValue)?defaultValue:sourceValue;
    }

    /**
     * Process name string
     *
     * @return the string
     */
    @Override
    public ProcessorName processName() {
        return ProcessorName.DEFAULT;
    }
}
